const express = require('express');
const app = express();
const bodyParser = require("body-parser");
const cors = require('cors');
const routes = require('./routes/index')

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(cors({
  origin: 'http://localhost:8080' // 允许的源地址，根据实际情况进行设置
}));
app.use(routes)


// 启动服务器
const port = process.env.PORT || 3000;
app.listen(port, () => {
  console.log(`Server running on port ${port}`);
});